# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer:
pkgname=ttf-droid
pkgver=20200215
pkgrel=1
pkgdesc="General-purpose fonts released by Google as part of Android."
url="http://code.google.com/android/"
arch="noarch"
license="Apache-2.0"
depends="fontconfig"
subpackages="$pkgname-nonlatin"
# added fontconfig configuration from:
# https://github.com/bohoomil/fontconfig-ultimate/tree/master/fontconfig_patches/fonts-settings
source="https://dev.alpinelinux.org/archive/android-fonts/android-fonts-4.2.2_r1.2.tar.gz
	http://www.cosmix.org/software/files/DroidSansMonoSlashed.zip
	http://www.cosmix.org/software/files/DroidSansMonoDotted.zip
	45-droid.conf
	65-ttf-droid-sans.conf
	65-ttf-droid-serif.conf
	90-tt-droid.conf
	"
builddir="$srcdir"

package() {
	mkdir -p "$pkgdir"/usr/share/fonts/$pkgname \
		"$pkgdir"/etc/fonts/conf.avail \
		"$pkgdir"/etc/fonts/conf.d

	local fonts="DroidSerif-Bold.ttf DroidSerif-BoldItalic.ttf
		DroidSerif-Italic.ttf DroidSerif-Regular.ttf DroidSans-Bold.ttf
		DroidSans.ttf DroidSansMono.ttf"

	for i in $fonts; do
		install -m644 "$srcdir"/"$i" \
			"$pkgdir"/usr/share/fonts/$pkgname/
	done

	for j in "$srcdir"/*.conf; do
		install -m644 "$j" \
			"$pkgdir"/etc/fonts/conf.avail/
		cd "$pkgdir"/etc/fonts/conf.d
		ln -sf /etc/fonts/conf.avail/${j##*/}
	done
}

nonlatin() {
	pkgdesc="General-purpose fonts released by Google as part of Android. Non-Latin language support"
	depends="fontconfig"
	local fonts="DroidKufi-Bold.ttf DroidKufi-Regular.ttf DroidNaskh-Bold.ttf
		DroidNaskh-Regular-SystemUI.ttf DroidNaskh-Regular.ttf
		DroidSansArabic.ttf DroidSansArmenian.ttf
		DroidSansDevanagari-Regular.ttf DroidSansEthiopic-Bold.ttf
		DroidSansEthiopic-Regular.ttf DroidSansFallback.ttf
		DroidSansFallbackFull.ttf DroidSansFallbackLegacy.ttf
		DroidSansGeorgian.ttf DroidSansHebrew-Bold.ttf
		DroidSansHebrew-Regular.ttf DroidSansJapanese.ttf
		DroidSansTamil-Bold.ttf DroidSansTamil-Regular.ttf
		DroidSansThai.ttf"

	mkdir -p "$subpkgdir"/usr/share/fonts/$subpkgname

	for k in $fonts; do
		install -m644 "$srcdir"/"$k" \
			"$subpkgdir"/usr/share/fonts/$subpkgname/
	done
}

sha512sums="63ebea1be1dc1335ccc019b7d72aa54376985a93a0ce83a0c496895a77974c3ba440bf9a4d7196aa1c9d82b967895587ee5512ca7a74370e92fbe913778f974a  android-fonts-4.2.2_r1.2.tar.gz
e279c650e18f5e3db462c016fd93516442e5bfbe92580e51b6759cfc19e3f81fbd7e262b1a521ecce6c5c4aa3c8e0687d3b00e1ecb46784a090b9fd92d01aa25  DroidSansMonoSlashed.zip
cc891348632480dbf52f1d515059416bddf8433103904e4e6954b52089f7b736ed6b2c917d0f4d3f32348805a939aea1e5e014271c6aaf672c5800021039ffe3  DroidSansMonoDotted.zip
96ddb50da19f4219544384417f9b8491e3e02ee1d922f475b2bcf13c38256d5ae0fc10b81e4d10ad0b6553430bf156e82ca2a7811b8e2a9c92bde2058e85c517  45-droid.conf
07d4ab208c1c1dd4fe04f113daa5cb6361cf042eedade643f714b91ab77d3e1fa39f72db7b63cfcb8b69343e2f258920206d0f2ba204574f57292088e3a6e126  65-ttf-droid-sans.conf
5257da5537202e742afb168dda000b41873cde45e49807546c3c09aca92fe2c83264a19c2f1835e449ef9c943bf0fdfa1d4020ec93d9b4ff9e505dc4cb7e2464  65-ttf-droid-serif.conf
5ab9cb21e871be887060620061bafaf826cafca71fac8f58d6e63ea5be3af282ab138fbecc38ca3d4c48d58720bec407e179f804747b6c35c69b825d06ef035a  90-tt-droid.conf"
